/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __PQ_Application_H__
#define __PQ_Application_H__

#include "ClientPrerequisites.h"
#include "GameScene.h"

namespace PQClient
{
	/*Singleton class that manage the whole application.
	@todo change this class to be the base of app(with window),
	such as WindowsApplication,LinuxApplication
	*/
	class Application
		: public Object//inherit to receive events
	{
	protected:
		Application();
		
	public:
		~Application();

		static Application& getSingleton()
		{
			static Application inst;
			return inst;

		}
		void init(HINSTANCE hInst);

		void createWindow();

		void processCmdLine(LPSTR strCmdLine)
		{
		}

		inline HINSTANCE getWinHInst()
		{
			if(!_hInst){
				assert("Not set");
			}

			return _hInst;
		}
		
		
		//Run this application,return exit state code
		int run();
		void update();
		void render();
		
		/*We need handle login success event.
		*/
		void handleEvent(Event* evt);

		
	protected:
		void configCurrentPath();

		void initOGRE();
		void defineResource();

	protected:
		HINSTANCE _hInst;
		HWND _hWnd;

		Ogre::Timer _timer;
		Ogre::Root *_root;
		Ogre::RenderWindow *_win;

		int _windowWidth;
		int _windowHeight;

		int _version;
		bool _inited;
		unsigned long _lastTime;
	};
}


#endif
